﻿using BaseGrpcEFCore.Entity;
using BaseGrpcServer.Entity;
using BaseGrpcServer.Repository;
using Microsoft.AspNetCore.Mvc;

namespace BaseGrpcServer.Controller
{
    [ApiController]
    [Route("[controller]")]
    public class UserController :ControllerBase
    {
        private readonly IUserRepository _userRepository;
        public UserController(BaseDbContext baseDbContext)
        {
            _userRepository = new UserRepository(baseDbContext);
        }

        [HttpGet]
        public IEnumerable<User> GetAll()
        {
            return _userRepository.GetAll();
        }

        [HttpGet("Init")]
        public bool Init()
        {
            return _userRepository.EnsureCreated();
        }
    }
}
